package com.cpi.cornpp.biweek.comparator;

import java.util.Comparator;

import com.cpi.cornpp.biweeks.view.BiWeekView;

public class BiWeekComparator implements Comparator {

	public int compare(Object biWeekView , Object biWeekViewToCompare) {
		int result = 0;
		int biWeek = 0;
		int month = 0; 
		int year = 0;

		int biWeekToCompare = 0;
		int monthToCompare = 0; 
		int yearToCompare = 0;

		biWeek = ((BiWeekView)biWeekView).getBiweek();
		biWeekToCompare = ((BiWeekView)biWeekViewToCompare).getBiweek();
		
		month = ((BiWeekView)biWeekView).getMonth();
		monthToCompare = ((BiWeekView)biWeekViewToCompare).getMonth();

		year = ((BiWeekView)biWeekView).getYear();
		yearToCompare = ((BiWeekView)biWeekViewToCompare).getYear();

				
		if (year < yearToCompare){
			result = -1;
		} else if (year > yearToCompare){
			result = 1;
		}else if (month < monthToCompare){
			result = -1;
		}else if(month > monthToCompare){
			result =1;
		}else if(biWeek < biWeekToCompare){
			result =-1;
		}else if(biWeek > biWeekToCompare){
			result = 1;
		}
		
		return result;
	}

}
